set(CMAKE_TOOLCHAIN_FILE cmake/ArduinoToolchain.cmake) # Arduino Toolchain


cmake_minimum_required(VERSION 2.8)
#====================================================================#
#  Setup Project                                                     #
#====================================================================#
project(InputController C CXX ASM)

#SET(ASM_OPTIONS "-x assembler-with-cpp")
#SET(CMAKE_ASM_FLAGS "${CFLAGS} ${ASM_OPTIONS}" )
SET(CMAKE_C_FLAGS "${CFLAGS} -std=gnu99 -O2" ) #-O2 optimization, otherwise delay.h complains

include_directories(${CMAKE_CURRENT_SOURCE_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/OS)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/TinyGPSPlus)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/WSWire)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/WSWire/utility)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/SoftwareSerial)

print_board_list()
print_programmer_list()

file(GLOB C_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS *.cpp TinyGPSPlus/*.cpp OS/*.cpp WSWire/utility/*.c WSWire/*.cpp SoftwareSerial/*.cpp)
#file(GLOB S_SRC RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} FOLLOW_SYMLINKS *.S)

generate_arduino_firmware(input_controller
SRCS ${C_SRC}
BOARD mega2560)

#add_custom_command(TARGET input_controller
#                   POST_BUILD
#                   COMMAND avr-objcopy -O ihex input_controller.elf input_controller.hex)

set(${FIRMWARE_NAME}_PORT /dev/ttyUSB0)
